<extend name="_layout/main" />
<block name="content">

	<div class="page-content">
		<div class="page-breadcrumbs">
			<ul class="breadcrumb">
				<li>
					<i class="fa fa-home"></i>
					<a href="{:U('dashboard/index')}">系统首页</a>
				</li>
				<li>
					<a href="{:U('announcement/square')}">公告管理</a>
				</li>
				<li class="active">添加公告</li>
			</ul>
		</div>
		<div class="page-body">
			<div class="row">
				<div class="col-xs-12 col-md-12">
					<div class="widget">
						<div class="widget-header bordered-bottom bordered-blue">
							<span class="widget-caption">添加公告</span>
						</div>
						<div class="widget-body">
							<div>
								<form id="form" style="overflow: hidden;" action="{:U('announcement/add')}" method="post">
									<div class="row">
										<div class="form-group col-md-5">
											<input type="text" class="form-control " id="title" name="title" placeholder="公告标题">

										</div>

										<div class="form-group  col-md-8">

											<?php echo form::editor('content','','full',800,500)?>

										</div>
										<input type="hidden" name="source" id="source" />
									</div>
									<div class="row">
										<div class="form-group  col-md-6">
											<button type="submit" class="btn btn-blue ladda-button" data-style="expand-right" id="submit"> <span class="ladda-label">确定保存</span></button>

										</div>

									</div>
								</form>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<script type="text/html" id="t_collection">
		<div class="row">
			<div class="col-md-12">
				<div class="form-group">
					<input type="text" id="collection_url" class="form-control" placeholder="输入文章地址" required="">
				</div>

			</div>
		</div>
	</script>
</block>

<block name="footer">
	<script src="__PUBLIC__/assets/js/jquery.form.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		var sl = Ladda.create(document.getElementById("submit"));
		$("#form").submit(function(e) {
			e.preventDefault();
			if ($("#title").val().length < 1) {
				tips("请输入公告标题", "danger");
				return false;
			}
			if (content_editor.hasContents() == false) {
				tips("请输入公告内容", "danger");
				return false;
			}
			sl.start();
			$(this).ajaxSubmit(function(result) {
				sl.stop();
				result = JSON.parse(result);
				if (result.status == 'success') {
					location.href = "{:U('announcement/index')}";
				} else {
					tips(result.message, 'danger');
					return false;
				}
			});
		});
	</script>

</block>